package com.platform.dao;

import com.platform.entity.ProductVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 
 * 
 * @author lipengjun
 * @email 939961241@qq.com
 * @date 2017-08-11 09:16:46
 */
public interface ApiProductMapper extends BaseDao<ProductVo> {
    @Update("update nideshop_product p set p.goods_number = p.goods_number - #{buyNumber} where p.id = #{productId} and p.goods_number >= #{buyNumber}")
    int decreaseGoodsNumber(@Param("productId") Integer productId, @Param("buyNumber") int buyNumber);

    @Update("update nideshop_product p set p.goods_number = p.goods_number + #{buyNumber} where p.id = #{productId}")
    int increaseGoodsNumber(@Param("productId") Integer productId, @Param("buyNumber") int buyNumber);
}
